/* eslint-disable prettier/prettier */
import { WebGLCanvas } from "@nirvana/canvas";
import { Cube, Scene, Entity, Camera } from "@nirvana/core";

// 使用使用 Canvas
let canvas = document.getElementById("engine-nirvana");
const webCanvas = new WebGLCanvas(canvas, {});
const engine = webCanvas.engine;
// const gl = engine.gl;

const scene: Scene = engine.sceneManager.createScene("root");
const camera = new Camera("first");
scene.addCamera(camera);

const entity: Entity = new Entity("root");
scene.addEntity(entity);

const vdata = new Float32Array([
  //前
  0.5, 0.5, 0.5, 0.0, 0.8, 0.0,
  -0.5, 0.5, 0.5, 0.0, 0.8, 0.0,
  -0.5, -0.5, 0.5, 0.0, 0.8, 0.0,
  0.5, -0.5, 0.5, 0.0, 0.8, 0.0,
  //后
  0.5, 0.5, -0.5, 0.6, 0.9, 0.0,
  -0.5, 0.5, -0.5, 0.6, 0.9, 0.0,
  -0.5, -0.5, -0.5, 0.6, 0.9, 0.0,
  0.5, -0.5, -0.5, 0.6, 0.9, 0.0,
  //上
  0.5, 0.5, -0.5, 0.5, 0.5, 0.0,
  -0.5, 0.5, -0.5, 0.5, 0.5, 0.0,
  -0.5, 0.5, 0.5, 0.5, 0.5, 0.0,
  0.5, 0.5, 0.5, 0.5, 0.5, 0.0,
  //下
  0.5, -0.5, -0.5, 0.5, 0.5, 0.0,
  -0.5, -0.5, -0.5, 0.5, 0.5, 0.0,
  -0.5, -0.5, 0.5, 0.5, 0.5, 0.0,
  0.5, -0.5, 0.5, 0.5, 0.5, 0.0,
  //右
  0.5, 0.5, -0.5, 0.9, 0.0, 0.2,
  0.5, 0.5, 0.5, 0.9, 0.0, 0.2,
  0.5, -0.5, 0.5, 0.9, 0.0, 0.2,
  0.5, -0.5, -0.5, 0.9, 0.0, 0.2,
  //左
  -0.5,0.5, -0.5, 0.6, 0.0, 0.6,
  -0.5, 0.5, 0.5, 0.6, 0.0, 0.6,
  -0.5, -0.5, 0.5, 0.6, 0.0, 0.6,
  -0.5, -0.5, -0.5, 0.6, 0.0, 0.6
]);

const iData = new Uint16Array([
  0, 1, 2, 0, 2, 3,
  4, 6, 5, 4, 7, 6,
  8, 9, 10, 8, 10, 11,
  12, 14, 13, 12, 15, 14,
  16, 17, 18, 16, 18, 19,
  20, 22, 21, 20, 23, 22
]);

// const cube = new Cube("cube-01");
// // scene.addEntity(cube);
// entity.add(cube);

// const plane = neew

// engine.update = (gl) => {
//   // console.log('--');
//   gl.clearColor(0.0, 0.0, 0.0, 1.0);
//   // 用上面指定的颜色清除缓冲区
//   gl.clear(gl.COLOR_BUFFER_BIT);

// };
